#ifndef ASTAR_H
#define ASTAR_H

#include <vector>
#include "AStarResult.h"
#include "Node.h"

class ANode;

class AStar {
public:
	AStar(std::vector<int> vec, int rowCount, int columnCount, int initialRow, int initialColumn, int finalRow, int finalColumn);
	~AStar();

	std::vector<AStarResult*> execute();
	std::vector<AStarResult*> getResult();

private:
	ANode* getLeastCostlyNode();
	void closeNode(ANode* node);
	void openAdjacents(ANode* node);
	std::vector<AStarResult*> calculateResult(ANode* node);

	bool isInOpened(ANode* node) const;
	bool isInClosed(ANode* node) const;
	void removeFromOpened(ANode* node);

	void calculateAdjacents();
	ANode* getNode(int row, int column);
	float getDistance(ANode* initialNode, ANode* finalNode);

	std::vector<ANode*> m_nodes;
	std::vector<ANode*> m_openedNodes;
	std::vector<ANode*> m_closedNodes;
	std::vector<AStarResult*> m_result;

	int m_initialRow;
	int m_initialColumn;
	int m_finalRow;
	int m_finalColumn;
	int m_rowCount;
	int m_columnCount;
};

#endif
